In [1]:
x=5
j=2
In [2]:
print(j)
In [4]:
import numpy as np
In [5]:
import matplotlib as plt
In [6]:
plt.plot(1,2)
In [11]:
np.arange(4,10, .1)
Out[11]:
In [12]:
ds = np.arange(1,10,2)
In [13]:
ds.ndim
Out[13]:
In [14]:
ds
Out[14]:
In [15]:
ds.shape
Out[15]:
In [16]:
ds.size
Out[16]:
In [17]:
ds.dtype
Out[17]:
In [18]:
ds.itemsize
Out[18]:
In [20]:
list(ds.data)
Out[20]:
In [21]:
x=ds.data
list(x)
Out[21]:
In [22]:
ds.data
Out[22]:
In [23]:
ds
Out[23]:
In [24]:
ds.size * ds.itemsize
Out[24]:
In [25]:
np.array([1,2,3,4,5])
Out[25]:
In [26]:
np.zeros((3,3))
Out[26]:
In [27]:
np.linespace(0,5, num=10)
In [31]:
np.linspace(1,2, num=20)
Out[31]:
In [32]:
np.random.random((0,100))
Out[32]:
In [38]:
# This gives you an M by N matrix with random number
random_array = np.random.random((1,10))
In [46]:
np.max(random_array)
Out[46]:
In [40]:
random_array
Out[40]:
In [47]:
np.min(random_array)
Out[47]:
In [48]:
np.mean(random_array)
Out[48]:
In [49]:
np.median(random_array)
Out[49]:
In [50]:
np.std(random_array)
Out[50]:
In [51]:
np.sum(random_array)
Out[51]:
In [52]:
np.reshape(random_array, (2,5))
Out[52]:
In [53]:
random_array
Out[53]:
In [55]:
np.ravel(random_array)
Out[55]:
In [57]:
import matplotlib.pyplot as plt
In [58]:
x= [0,1,2]
y= [0,1,4]
fig = plt.figure()
axes = fig.add_subplot(111)
axes.plot(x,y)
plt.show()
In [78]:
x_highres = np.linspace(0, 2, 20)
y_highres = x_highres ** 2
fig = plt.figure()
axes = fig.add_subplot(111)
axes.set_title("This is a title")
axes.plot(x, y, color="black", linestyle="dashed", marker='o')
axes.plot(x_highres, y_highres, color="red")
axes.grid()
plt.show()
In [65]:
x_highres
Out[65]:
In [79]:
x_highres = np.linspace(0, 2, 20)
y_highres = x_highres ** 2
fig = plt.figure()
axes = fig.add_subplot(111)
axes.set_title("$y=x^2$")
axes.plot(x, y, color="black", linestyle="dashed", marker='o')
axes.plot(x_highres, y_highres, color="red")
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.grid()
plt.show()
In [84]:
x_highres = np.linspace(0, 2, 20)
y_highres = x_highres ** 2
fig = plt.figure(figsize=(12, 12))
axes = fig.add_subplot(111)
axes.set_title("$y=x^2$")
axes.plot(x, y, color="black", linestyle="dashed", marker='o')
axes.plot(x_highres, y_highres, color="red")
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.grid()
plt.show()
In [93]:
noise = np.random.random((128,128)) * 100
In [94]:
noise
Out[94]:
In [95]:
plt.imshow(noise)
plt.colorbar()
plt.show()
In [96]:
plt.imshow(noise, cmap=plt.cm.gray)
plt.colorbar()
plt.show()
In [100]:
plt.imshow(noise, cmap=plt.cm.Paired)
plt.colorbar()
plt.show()
In [ ]: